﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MemberLayout.master" AutoEventWireup="true"
    CodeBehind="User.aspx.cs" Inherits="ChatForum.Client.Admin.User" %>

<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" runat="server">
    <div id="actionPanelDiv" class="actionPanel borderStyle">
        <table>
            <tr>
                <td>
                    <asp:ImageButton CssClass="leftSideIcon" ToolTip="Block Selected Users" ImageUrl="~/images/block.png"
                        OnClick="OnBlockUser" AlternateText="Block" runat="server" />
                    <asp:ImageButton CssClass="leftSideIcon" ToolTip="Unblock Selected Users" ImageUrl="~/images/unblock.png"
                        OnClick="OnUnblockUser" AlternateText="Un Block" runat="server" />
                    <asp:ImageButton CssClass="leftSideIcon" ToolTip="Send Email to Selected Users" ImageUrl="~/images/email.png"
                        AlternateText="Email" OnClientClick="Email.ShowPopup(this, event); return false;"
                        runat="server" Width="24" Height="24" />
                    <%--<asp:ImageButton CssClass="leftSideIcon" ToolTip="Send SMS to Selected Users" ImageUrl="~/images/sms.png" AlternateText="SMS" runat="server" Width="24" Height="24" />--%>
                </td>
                <td style="text-align: right">
                    <div>
                        <asp:TextBox ID="txtSearchUser" runat="server" OnTextChanged="FilterUser" AutoPostBack="true" />
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div id="userListDiv" style="overflow: auto">
        <asp:UpdatePanel runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="txtSearchUser" EventName="TextChanged" />
            </Triggers>
            <ContentTemplate>
                <asp:GridView runat="server" ID="userListGrid" AutoGenerateColumns="false" GridLines="Horizontal"
                    OnRowDataBound="userListGrid_RowDataBound" CellPadding="8">
                    <HeaderStyle CssClass="gridHeaderStyle" />
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:CheckBox CssClass="userSelectorClass" ID="userSelector" runat="server" /></ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:Image ID="Image1" ImageUrl='<%# ((string)Eval("Sex")).StartsWith("m", StringComparison.CurrentCultureIgnoreCase) ? "~/images/male.png" : "~/images/female.png" %>'
                                    Width="30" Height="30" runat="server" /></ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:ImageButton ID="userOnlineImageId" ImageUrl='<%# (bool)Eval("IsOnline") ? "~/images/online.png" : "~/images/offline.png" %>'
                                    Width="20" Height="20" runat="server" /></ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="UserId" HeaderText="ID" />
                        <asp:BoundField DataField="Country" HeaderText="Country" />
                        <asp:BoundField DataField="MobileNo" HeaderText="Mobile" />
                        <asp:BoundField DataField="EmailId" HeaderText="Email" />
                        <asp:BoundField DataField="LastLogInTime" HeaderText="Last LogIn" DataFormatString="{0:f}" />
                        <asp:BoundField DataField="DateOfBirth" HeaderText="Date Of Birth" DataFormatString="{0:MM/dd/yyyy}" />
                    </Columns>
                </asp:GridView>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div class="centerDiv borderWithbackground" id="emailDiv">
        <div style="text-align: right;">
            <asp:ImageButton ImageUrl="~/images/close.png" OnClientClick="Email.HidePopup(); return false;"
                Height="20px" Width="20px" runat="server" />
        </div>
        <div style="margin-left: 5px; margin-right: 5px; height: 450px;">
            <asp:Label Text="Subject" runat="server" />
            <asp:TextBox ID="txtMailSubject" Width="99%" runat="server" />
            <br />
            <br />
            <asp:Label Text="Message" runat="server" />
            <asp:TextBox ID="txtMailBody" Width="99%" Height="360" TextMode="MultiLine" runat="server" />
            <asp:ImageButton ImageUrl="~/images/sendEmail.png" AlternateText="Send" OnClientClick="Utility.EnableDiv('actionPanelDiv'); Utility.EnableDiv('userListDiv')"
                OnClick="OnEmailRequest" runat="server" />
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="scriptContent" runat="server">
    <script type="text/javascript">
        var Email = function () {
            return {
                ///////////////////////////////
                /// PUBLIC
                ///////////////////////////////
                ShowPopup: function (sender, event) {
                    //checking any selection made or not
                    var allRow = document.querySelectorAll('.userSelectorClass');
                    var minimumOneUserSelected = false;
                    for (var i = 0; i < allRow.length; i++) {
                        if (allRow[i].firstChild.checked == true) {
                            minimumOneUserSelected = true;
                            break;
                        }
                    }

                    if (minimumOneUserSelected == false) {
                        alert("Please select at least one user.");
                        return;
                    }

                    Utility.DisableDiv('actionPanelDiv');
                    Utility.DisableDiv('userListDiv');

                    //Clearing Reply Text Area
                    document.getElementById('<%=txtMailSubject.ClientID %>').value = '';
                    document.getElementById('<%=txtMailSubject.ClientID %>').focus();
                    document.getElementById('<%=txtMailBody.ClientID %>').value = '';

                    var emailDiv = document.getElementById('emailDiv');
                    emailDiv.style.display = 'block';
                },
                HidePopup: function () {
                    var emailDiv = document.getElementById('emailDiv');
                    emailDiv.style.display = 'none';
                    Utility.EnableDiv('actionPanelDiv');
                    Utility.EnableDiv('userListDiv');
                }
            }
        } ();
    </script>
</asp:Content>
